package com.yangkunhong.service;

import com.yangkunhong.constant.ErrMsg;
import com.yangkunhong.dao.UserDao;
import com.yangkunhong.dao.UserLogDao;
import com.yangkunhong.pojo.UserLog;

import java.util.Map;

public class UserLogService {

    public ErrMsg deleteById(Map<String,String> params){

        if(UserLogDao.deleteById(Integer.valueOf(params.get("id")))){
            return ErrMsg.OK;
        }else{
            return ErrMsg.ERROR;
        }

    }
    public UserLog getOneById(int id){

        return UserLogDao.getOneById(id);



    }

    public ErrMsg doUpdate(Map<String,String> map) {

        System.out.println(map);
        UserLog userLog = new UserLog();
        System.out.println(map.get("id"));
        userLog.setId(Integer.valueOf(map.get("id")));
        userLog.setUserId(Integer.valueOf(map.get("userId")));
        userLog.setCreateIp(map.get("createIp"));
        userLog.setUserAgent(map.get("userAgent"));
        userLog.setCreateAt(map.get("createAt"));
        userLog.setOp(map.get("op"));

        if(UserLogDao.update(userLog)!=1){
            return ErrMsg.ERROR; //修改失败
        }
        return ErrMsg.OK;
    }
}
